package website.digitalocean.chapter14;

import java.util.Scanner;

/**
 * @Author: 582895699@qq.com
 * @Desctription:
 * @Date: Created in 2023/2/13 22:46
 */
public class ATMDispenseChain {

    private DispenseChain fifty;

    public ATMDispenseChain() {
        fifty = new Dollar50Dispenser();
        DispenseChain twentyDispense = new Dollar20Dispenser();
        DispenseChain tenDispense = new Dollar10Dispenser();
        fifty.sendNextChain(twentyDispense);
        twentyDispense.sendNextChain(tenDispense);
    }

    public static void main(String[] args) {
        ATMDispenseChain atmDispenseChain = new ATMDispenseChain();
        while (true) {
            int amount = 0;
            System.out.println("Enter amount to dispense");
            Scanner input = new Scanner(System.in);
            amount = input.nextInt();
            if (amount % 10 != 0) {
                System.out.println("Amount should be in multiple of 10s.");
                return;
            }
            atmDispenseChain.fifty.dispense(new Currency(amount));
        }
    }
}